package main;

import gui.klan.UserFrame;

import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import base.patterns.delegate.Delegate;
import base.patterns.delegate.Delegate.Slot;
import base.patterns.operation.Function;


public class ApplicationContext {

	private String name;
	
    public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void sayHello()
    {
      System.out.println("App name is '" + name + "'");
    }

 	public void run() {
		UserFrame<String> frame = new UserFrame<String>();		
		
		Delegate.connect(frame.initFrame, new Slot<Void, JFrame> ( new Function<Void, JFrame>() {

			@Override
			public Void call(JFrame frame) {
				FlowLayout flowLayout = new FlowLayout();
				flowLayout.setAlignment(FlowLayout.LEFT);
				frame.setLayout(flowLayout);
				
				JButton jButton1 = new JButton("Click");
				JTextArea jTextArea = new JTextArea( "test" );
				frame.getContentPane().add( new JScrollPane(jTextArea));
				frame.getContentPane().add(jButton1);
				
				frame.setSize(400, 200);
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				return null;
			}
		})); 
		
		frame.show();
	}

}
